package com.youdianda.controller;


import com.youdianda.dto.ArticleQueryPageDTO;
import com.youdianda.dto.CateQueryPageDTO;
import com.youdianda.entity.YddArticle;
import com.youdianda.result.Result;
import com.youdianda.service.IYddArticleService;
import com.youdianda.vo.ArticleQueryPageVO;
import com.youdianda.vo.CateQueryPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mosen
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_article")
public class YddArticleController {
    @Autowired
    private IYddArticleService yddArticleService;

    /**
     * 文章分页查询
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public Result<ArticleQueryPageVO> articlePage(ArticleQueryPageDTO dto){
        return yddArticleService.articlePage(dto);
    }

    /**
     * 新增文章
     * @param yddArticle
     * @return
     */
    @PostMapping("/add")
    public Result<YddArticle> addArticle(@RequestBody YddArticle yddArticle){
        return yddArticleService.addArticle(yddArticle);
    }

    /**
     * 根据文章id查询
     * @param
     * @return
     */
    @GetMapping("/rowInfo")
    public Result<YddArticle> ArticleById(String  id){
        return yddArticleService.ArticleById(id);
    }

    /**
     * 修改文章
     * @param   yddArticle
     * @return
     */
    @PostMapping("/update")
    public Result<YddArticle> updateArticle(@RequestBody YddArticle yddArticle){
        return yddArticleService.updateArticle(yddArticle);
    }

    /**
     * 根据文章id删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result<YddArticle> delArticle(String  id){
        return yddArticleService.delArticle(id);
    }
}
